/**
 * copyright(c) 2013 www.jiongshibaoliao.com, All Rights Reserved.
 * project: jiongshibaoliao 
 * author: 曾帅
 * date: 2014-1-25 上午10:22:30
 * version: v1.0
 */

package com.jiongshibaoliao.model.bean;

import java.util.Arrays;
import java.util.Properties;

import org.springframework.beans.factory.annotation.Value;

/**
 * @project jiongshibaoliao
 * @author 曾帅
 * @version 1.0
 * @date 2014-1-25 上午10:22:30
 */

public class MailBean {
	
	@Value("${mail.server.host}")
	private String mailServerHost;
	
	@Value("${mail.server.port}")
	private String mailServerPort;
	
	@Value("${mail.server.fromAddress}")
	private String fromAddress;
	
	@Value("${mail.server.userName}")
	private String userName;
	
	@Value("${mail.server.password}")
	private String password;
	
	private String toAddress;
	
	private boolean isValidate = true;
	
	private String subject;
	
	private String content;
	
	private String[] attachFileNames;

	public Properties getProperties() {
		Properties properties = new Properties();
		properties.put("mail.smtp.host", this.mailServerHost);
		properties.put("mail.smtp.port", this.mailServerPort);
		properties.put("mail.smtp.auth", isValidate ? "true" : "false");
		return properties;
	}
	
	public MailBean(String toAddress, String subject, String content) {
		this.toAddress = toAddress;
		this.subject = subject;
		this.content = content;
	}

	public MailBean(String mailServerHost, String mailServerPort,
			String fromAddress, String userName, String password,
			String toAddress, boolean isValidate, String subject,
			String content, String[] attachFileNames) {
		this.mailServerHost = mailServerHost;
		this.mailServerPort = mailServerPort;
		this.fromAddress = fromAddress;
		this.userName = userName;
		this.password = password;
		this.toAddress = toAddress;
		this.isValidate = isValidate;
		this.subject = subject;
		this.content = content;
		this.attachFileNames = attachFileNames;
	}

	@Override
	public String toString() {
		return "MailBean [attachFileNames=" + Arrays.toString(attachFileNames)
				+ ", content=" + content + ", fromAddress=" + fromAddress
				+ ", isValidate=" + isValidate + ", mailServerHost="
				+ mailServerHost + ", mailServerPort=" + mailServerPort
				+ ", password=" + password + ", subject=" + subject
				+ ", toAddress=" + toAddress + ", userName=" + userName + "]";
	}

	public String getMailServerHost() {
		return mailServerHost;
	}

	public void setMailServerHost(String mailServerHost) {
		this.mailServerHost = mailServerHost;
	}

	public String getMailServerPort() {
		return mailServerPort;
	}

	public void setMailServerPort(String mailServerPort) {
		this.mailServerPort = mailServerPort;
	}

	public boolean isValidate() {
		return isValidate;
	}

	public void setValidate(boolean isValidate) {
		this.isValidate = isValidate;
	}

	public String[] getAttachFileNames() {
		return attachFileNames;
	}

	public void setAttachFileNames(String[] fileNames) {
		this.attachFileNames = fileNames;
	}

	public String getFromAddress() {
		return fromAddress;
	}

	public void setFromAddress(String fromAddress) {
		this.fromAddress = fromAddress;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getToAddress() {
		return toAddress;
	}

	public void setToAddress(String toAddress) {
		this.toAddress = toAddress;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String textContent) {
		this.content = textContent;
	}
}
